import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'


// https://vite.dev/config/
export default defineConfig({
    base: '/',
    plugins: [
        vue()
    ],
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url))
        },
    },
    server:{
        host:'0.0.0.0',
        allowedHosts: ['zjtest.sz56t.com','abc.sz56t.com'], // Add this line to allow your host
        proxy: {
            // 匹配所有以 /api 开头的请求
            '/api': {
                target: 'http://localhost:8989', // 目标地址
                changeOrigin: true,
                rewrite: path => path.replace(/^\/api/, ''), // 可选：去掉前缀
            },
            '/proxy': {
                target: 'http://localhost:9591/proxy',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/proxy/, ''),
            },
        }
    }
})

